drop table customers;
drop sequence cust_Seq;
create table customers(id number(6,0) primary key, name varchar2(15), sal number(8,2), sex varchar(1), birth date);
create sequence cust_Seq start with 1 increment by 1;





drop table cust_favo;
drop sequence cust_favo_Seq;
create table cust_favo(id number(6,0) primary key, cust_id number(6,0), favo_id number(6,0));
create sequence cust_favo_Seq start with 1 increment by 1;

drop table favorites;


drop sequence cust_Seq;

drop sequence favo_Seq;

drop sequence cust_favo_Seq;

create table customers(id number(6,0) primary key, name varchar2(15), sal number(8,2), sex varchar(1), birth date);

create table favorites(id number(6,0) primary key, name varchar2(20));

create table cust_favo(id number(6,0) primary key, cust_id number(6,0), favo_id number(6,0));

create sequence cust_Seq start with 1 increment by 1;

create sequence favo_Seq start with 1 increment by 1;

create sequence cust_favo_Seq start with 1 increment by 1;

select * from users;

select * from favotite;

select * from favorites

-- 查找customer信息
select * from CUSTOMERS c 
left join CUST_FAVO cf on c.id = cf.cust_id
left join FAVORITES f on cf.favo_id = f.id


-- 根据cust_id， 查询 其爱好信息

select * from CUSTOMERS c
left join CUST_FAVO cf on c.id = cf.cust_id 
left join FAVORITES f on cf.favo_id = f.id


select f.id, f.name from cust_favo cf
left join FAVORITES f on cf.favo_id = f.id
left join 


select cust_Seq.nextval as id from dual

select max(id) from CUSTOMERS

select c.id, c.name, c.sal, c.sex, c.birth from CUSTOMERS c 
left join CUST_FAVO cf on c.id = cf.cust_id
			left join FAVORITES f on cf.favo_id = f.id

			
select c.id id, c.name name, c.sal sal, c.sex sex, c.birth birth from CUST_FAVO cf
left join CUSTOMERS c  on c.id = cf.cust_id 
left join FAVORITES f on cf.favo_id = f.id 

			
			